using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Super;

namespace Super
{
    public class RadarMap : MonoBehaviour
    {
        public RadarImage radarImage;
        public RadarFG radarFG;
        public RadarFG.ForegroundType foregroundType;
        public float length;        //最长长度
        public float offsetRotate;      //偏转角度
        [Range(0, 1)]
        public List<float> points = new List<float>();//数据列表

        public void OnValidate()
        {
            Init(length, offsetRotate, foregroundType);
            Refresh(points);
        }

        public void Init(float length, float offsetRotate, RadarFG.ForegroundType foregroundType)
        {
            radarImage.length = length;
            radarImage.offsetRotate = offsetRotate;
            radarFG.length = length;
            radarFG.offsetRotate = offsetRotate;
            radarFG.foregroundType = foregroundType;
        }

        public void Refresh(List<float> points)
        {
            this.points = points;
            radarImage.points = points;
            radarFG.segments = points.Count;
            radarImage.SetVerticesDirty();
            radarFG.SetVerticesDirty();
        }
    }
}

